package cj.web.login.controllers;

import javax.servlet.http.HttpServletRequest;

import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.portal.Portal;
import net.paoding.rose.web.portal.PortalSetting;
import net.paoding.rose.web.var.Model;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@Path("demo")
public class DemoController {
	
	protected static final Log logger = LogFactory.getLog(DemoController.class); 
	
	@Get("umedit")
	public String umedit(Model model)
	{
		return "/views/umeditdemo.vm";
	}
	
	@Get("uedit")
	public String uedit(Model model)
	{
		return "/views/ueditdemo.vm";
	}
	
	@Get("imageDemo")
	public String imageDemo(Model model,HttpServletRequest request)
	{
		// 文件保存路径  
//    	String realPath = request.getSession().getServletContext().getRealPath("/");
//		String filePath="/upload/8491450405538067.jpg";
//		String path = new File(realPath).getParent() + filePath;
//		String imgbase64 = ImageUtils.GetImageStr(path);
//		model.add("imgs",imgbase64);
		return "/views/imageDemo.vm";
	}
	
	@Get("/3.7")
	@PortalSetting(timeout = 100)
    public String portal(Portal portal) {
        portal.addWindow("p1", "/demo/wp1");
        portal.addWindow("p2", "/demo/wp2");
        return "/views/portalDemo.vm";
    }

    @Get("/wp1")
    public String portal1() {
        return "@this is p1";
    }

    @Get("/wp2")
    public String portal2() {
        return "@this is p2";
    }
}